package com.itheima.Zixi4.ZuoYe.Zuoye3;

import java.util.Objects;

public class Laomo implements Comparable<Laomo>{
    private String name;
    private int age;

    @Override
    public int compareTo(Laomo o) {
        if(this.age == o.age){
            return this.name.compareTo(o.name);
        }else{
            return Integer.compare(this.age, o.age);
        }
        }


    @Override
    public String toString() {
        return "Laomo{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Laomo laomo = (Laomo) o;
        return age == laomo.age && Objects.equals(name, laomo.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Laomo(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
